package crm8000.Controllers

import grails.converters.JSON

class UserController {

    static allowedMethods = [doLogin: 'POST']

	def userService

	def login() {
		if (session.loginUserId) {
			redirect(uri: "/")
		}
	}
	
	def doLogin() {
		def result = userService.doLogin()
		
		if (result.success) {
			session.loginUserId = result.id
		}
		
		render result as JSON
	}
}
